#include "stdafx.h"
#include "../mayashared/mayashared.h"
#include <maya/MFnPlugin.h>

#include "exportMesh.h"

HINSTANCE g_hInstance;

BOOL WINAPI DllMain(HINSTANCE hInst,DWORD reason,void *reserved)
{
	g_hInstance = hInst;
	return TRUE;
}

#pragma warning(disable:4190)

extern "C"
{
	__declspec(dllexport) MStatus initializePlugin(MObject obj)
	{
		MStatus res;

		try
		{
			InitMayaShared();

			MFnPlugin plugin(obj);

			res = plugin.registerCommand("exportMesh",ExportMeshCmd::Create);
			if(res != MStatus::kSuccess)
				throw Exception("Couldn't register the exportMesh command");

			return MStatus::kSuccess;
		}
		catch(const Exception &err)
		{
			MGlobal::displayError(err.GetErrorMessage().c_str());
			return MStatus::kFailure;
		}	
	}
	__declspec(dllexport) MStatus uninitializePlugin( MObject obj )
	{ 
		try
		{
			FreeMayaShared();

			MFnPlugin plugin(obj);

			plugin.deregisterCommand("exportMesh");

			return MStatus::kSuccess;
		}
		catch(const Exception &err)
		{
			MGlobal::displayError(err.GetErrorMessage().c_str());
			return MStatus::kFailure;}
	}
}